//app.js
const cloudsets = require('_self/application.js').CloudSetting;
const cloud = require('_self/cloud.js');
App({
  globalData:{
    openid:'',
    userInfo:null
  },
  //先序执行的函数
  onLaunch: function() {
    this.InitCloud();
  },
  InitCloud() {
    var that = this;
    wx.getStorage({
      key: 'wxuserinfo',
      success: function (res) {
        that.globalData.userInfo = res.data
      },
    })
    if (cloudsets.UseCloud) {
      console.log('* 云开发 * √' + ' 服务器:' + cloudsets.CloudId)
      if (!wx.cloud) {
        console.log(' -- 不支持云开发 -- ')
      } else {
        wx.cloud.init({
          env: cloudsets.CloudId,
          traceUser: cloudsets.TraceUser
        })
        //缓存信息
        cloud.CallCloudFuncAndSetStorge('openapi', cloudsets.AdaptStorge, 'userinfo',{action:'getOpenData'}).then(function (res) {
          if (res != 'callfuncfail') {
            //console.log(res)
            that.globalData.openid = res //给全局变量 openid 赋值
          }
        })

      }
    } else {
      console.log('* 云开发 * X')

    }
  },
  ModeServer(){
    //模式验证函数,检验是否是管理员 用户 / 黑名单用户
    
  }

})